package com.sywb.chuangyebao.view;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sywb.chuangyebao.R;
import com.sywb.chuangyebao.contract.ListCheckContract;

import org.bining.footstone.widget.DrawableEditText;
import org.bining.footstone.widget.PullToRefreshView;

import java.util.LinkedHashMap;

import butterknife.BindView;
import butterknife.OnClick;


public class SearchPeopleActivity extends ActionbarActivity<ListCheckContract.Presenter> implements ListCheckContract.ListCheckView {

    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.et_search)
    DrawableEditText etSearch;
    @BindView(R.id.tv_search)
    TextView tvSearch;
    @BindView(R.id.common_recycler)
    RecyclerView commonRecycler;
    @BindView(R.id.common_refresh)
    PullToRefreshView commonRefresh;
    @BindView(R.id.common_nodata_content)
    TextView commonNodataContent;
    @BindView(R.id.common_nodata_icon)
    ImageView commonNodataIcon;
    @BindView(R.id.common_nodata_subtitle)
    TextView commonNodataSubtitle;
    @BindView(R.id.common_nodata)
    RelativeLayout commonNodata;

    private int type;//
    private int question_id;

    @Override
    public int getLayoutId(Bundle bundle) {
        return R.layout.activity_search_people;
    }

    @Override
    public void initView(Bundle bundle) {
        super.initView(bundle);
        if (bundle == null) {
            question_id = getIntent().getIntExtra("p0", 0);
        } else {
            question_id = bundle.getInt("p0");
        }

    }

    @Override
    public void initPresenter() {
        mPresenter.initPresenter(this);
        mPresenter.initSearchPeopleView();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        outState.putInt("p0", question_id);
        super.onSaveInstanceState(outState);
    }

    @OnClick({R.id.iv_back, R.id.tv_search})
    public void onClick(View view) {
        if (!isCanClick(view)) return;
        switch (view.getId()) {
            case R.id.iv_back:
                exit();
                break;
            case R.id.tv_search:
                showProgress();
                mPresenter.listPeople(question_id, etSearch.getText().toString());
                break;
        }
    }

    @Override
    public PullToRefreshView getPullToRefreshView() {
        return commonRefresh;
    }

    @Override
    public RecyclerView getRecyclerView() {
        return commonRecycler;
    }

    @Override
    public void setNoData(boolean isNoData) {
        commonNodata.setVisibility(isNoData ? View.VISIBLE : View.GONE);
    }

    @Override
    public void setAskConfirmText(LinkedHashMap<Integer, String> checked) {

    }
}
